package es.mgil.whoWantsToBeAMillonaire.handlers;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.widget.Toast;
import es.mgil.whoWantsToBeAMillonaire.R;
import es.mgil.whoWantsToBeAMillonaire.runnables.SendScoreRunnable;

public class SendScoreHandler extends Handler {
	private Context context;

	public SendScoreHandler(Context context) {
		this.context = context;
	}

	@Override
	public void handleMessage(Message msg) {
		switch (msg.what) {
		case SendScoreRunnable.SEND_SCORE_ERROR_NAME:
			// a name should be indicated in settings
			Toast.makeText(context, R.string.play_send_score_error_name,
					Toast.LENGTH_LONG).show();
			break;
		case SendScoreRunnable.SEND_SCORE_ERROR_COORDINATES:
			// coordinates should be indicated in settings
			Toast.makeText(context, R.string.play_send_score_error_coordinate,
					Toast.LENGTH_LONG).show();
			break;
		case SendScoreRunnable.SEND_SCORE_ERROR_SERVER:
			// an error occurred in the server
			Toast.makeText(context, R.string.play_send_score_error_server,
					Toast.LENGTH_LONG).show();
			break;
		case SendScoreRunnable.SEND_SCORE_OK:
			// score sent correctly
			Toast.makeText(context, R.string.play_send_score_ok,
					Toast.LENGTH_LONG).show();
			break;
		default:
			break;
		}
	}
}